/**
 * Created by Administrator on 2017/10/31.
 */
const webpack = require("webpack");
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");       //生成Html模板
const CleanWebpackPlugin = require("clean-webpack-plugin");    //清除dist上面多余的文件
const UglifyJSPlugin = require("uglifyjs-webpack-plugin");

module.exports = {
    entry:{
 //       app:"./src/index.js",
 //       print:"./src/print.js"
        app:"./src/index.js"
    },
    devtool:"inline-source-map",               //用资源地图来定位错误
    devServer: {                                //禁用文本编辑器的安全写入功能
        contentBase: './dist',
        hot: true
    },
    module:{
        rules:[
            {
                test:/\.css$/,
                use:[
                    'style-loader',
                    'css-loader'
                ]
            }
        ]
    },
    plugins:[
        new CleanWebpackPlugin(["dist"]),
        new HtmlWebpackPlugin({
            title:"Output Management"
        }),
        new webpack.NamedModulesPlugin(),
        new webpack.HotModuleReplacementPlugin(),
     //   new UglifyJSPlugin()
    ],
    output:{
        filename:"[name].bundle.js",
        path:path.resolve(__dirname,'dist')   //注意两个下划线
    }
};